<%@ page language="java" import="com.alibaba.fastjson.JSONObject" pageEncoding="UTF-8" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.hrm.HrmUserVarify" %>
<%@ page import="weaver.hrm.User" %>
<%--获取流水号--%>
<%
    String id = Util.null2String(request.getParameter("id"));
    User user = HrmUserVarify.getUser(request, response);
    String curuserid = user.getUID() + "";
    RecordSet rs = new RecordSet();
    JSONObject jsonData = new JSONObject();
    boolean flag = hasPaper(id, curuserid);
    String message="";
    if (!flag) {
        message = "只有出卷人才能发送试卷";
    } else {
        rs.executeUpdate("update uf_sjtz set sfyfs=0 where id=?", id);
        message = "在线考试流程操作成功";
    }
    jsonData.put( "flag", flag );
    jsonData.put("message", message);
    out.print( jsonData.toJSONString() );

%>
<%!
    /**
     * 判断是否是出卷人
     */
    public static boolean hasPaper(String id, String userid) {
        RecordSet rs = new RecordSet();
        rs.executeQuery("select count(id) from uf_sjtz where id=? and cjr=?", id, userid);
        rs.next();
        return Util.getIntValue(rs.getString(1)) > 0;
    }
%>